//
//  DrawTrailerTableViewCell.m
//  JxCarios
//
//  Created by xcq on 15/2/3.
//  Copyright (c) 2015年 xiongchuanqi. All rights reserved.
//

#import "DrawTrailerTableViewCell.h"


@implementation DrawTrailerTableViewCell

- (void)awakeFromNib {
    _tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(praiseAction)];
    [_praiseView addGestureRecognizer:_tap];
    
    _shopLogo.layer.cornerRadius = 5.0f;
    _shopLogo.layer.masksToBounds = YES;
}

- (void)praiseAction {
    _praiseNum --;
    _paiseLable.text = [NSString stringWithFormat:@"%.0f",_praiseNum];
    //TODO:上传服务器
}

- (void)setInfo:(NSDictionary *)info{
    if (info) {
        _info = info;
        [_shopLogo setImageWithURL:[NSURL URLWithString:[info customObjectForkey:@"SHOP_LOGO"]] placeholderImage:nil options:SDWebImageProgressiveDownload ];
        _shopMz.text = [info customObjectForkey:@"SHOP_NAME"];
         NSString *str = @"￥";
        CGFloat distance = [[info objectForKey:@"SFZ"] doubleValue] / 1000;
        _distanceLabel.text = [[NSString stringWithFormat:@"%.1f",distance] stringByAppendingString:@"km"];         _paiseLable.text = [info customObjectForkey:@"GOOD_NUM"];
        _praiseNum = [[info customObjectForkey:@"GOOD_NUM"] doubleValue];
        if([_superType isEqualToString:@"carAround"]){ //车周边列表用
            _noDrawPrice.hidden = NO;
            _noDrawRawPrice.hidden = NO;
            _PreferentialImg.hidden = NO;
            _priceLabel.hidden = YES;
            if ([[info customObjectForkey:@"MINPRICE"] isEqualToString:@""]) {//如果没有促销价格
                if ([[info customObjectForkey:@"FIRSTPRICE"] isEqualToString:@""]) {// 如果没有售价
                    _noDrawPrice.hidden = YES;
                    
                } else {
                    _noDrawPrice.text = [str stringByAppendingString:[info customObjectForkey:@"FIRSTPRICE"]];
                }
                _noDrawRawPrice.hidden = YES;
                _noDrawPriceLine.hidden = YES;
                _PreferentialImg.hidden = YES;
            }else{
                _noDrawPrice.text = [str stringByAppendingString:[info customObjectForkey:@"MINPRICE"]];
                _noDrawRawPrice.text = [str stringByAppendingString:[info customObjectForkey:@"FIRSTPRICE"]];
                _noDrawPriceLine.hidden = NO;
            }
            
//            if ([[info customObjectForkey:@"FIRSTPRICE"] isEqualToString:@""]) {
//                _noDrawPrice.hidden = YES;
//                _noDrawPriceLine.hidden = YES;
//                _PreferentialImg.hidden = YES;
//            }else {
//                _noDrawRawPrice.text = [str stringByAppendingString:[info customObjectForkey:@"FIRSTPRICE"]];
//                _noDrawPriceLine.hidden = NO;
//            }
         }else if([_superType isEqualToString:@"cell"]){ //商品详情中需要支付用
            _PreferentialImg.hidden = NO;
            _priceLabel.hidden = YES;
        }else if ([_superType isEqualToString:@"notPay"]){//商品详情不需要支付用
            
        }else{ //拖车商家列表用
            if (![[info customObjectForkey:@"MINPRICE"] isEqualToString:@""]) {
                _priceLabel.text = [str stringByAppendingString:[info customObjectForkey:@"MINPRICE"]];
                return;
            }
            if (![[info customObjectForkey:@"FIRSTPRICE"] isEqualToString:@""]) {
                _priceLabel.text = [str stringByAppendingString:[info customObjectForkey:@"FIRSTPRICE"]];
                return;
            }
            _priceLabel.hidden = YES;
          
         }
    }
 
 
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
